//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<XEditorFrame.h>
///	@path	~/src/editor/xedit/
///	@date	2008/09/04
///	@brief	.

#pragma once

#include "xeres.h"

#include "lib/utilities/time.h"

#include "gui/composite/composition.h"
#include "gui/xgui/XFrame.h"

namespace xeres {

	/*! 
		\class	FrameBase
		\brief	Interface of holder of frame.
	*/
	class FrameBase
	{
	public:

		/// \brief	Get client form instance of frame.
		virtual RefWeak<IGuiForm> GetClientForm( void ) = 0;

		/// \brief	Acquire update of frame.
		virtual void AcquireUpdate( void ) = 0;

		/// \brief	Set title of frame.
		virtual void SetTitle( const wchar_t * title ) = 0;

		/// \brief	Get hwnd.
		virtual HWND GetHwnd( void ) = 0;
	};

	/*! 
		\class	XEditorFrame
		\brief
	*/
	class XEditorFrame : public XFrame , public InputTranslator
	{
	public:

		/// \ctor
		XEditorFrame( FrameBase& window );

		/// \dtor
		virtual ~XEditorFrame( void );

		DECL_IOBJECT_CLASS( XEditorFrame , XFrame );

	public:

		/// \name Attribute of XEditorFrame
		//@{

		/// \brief	Get rendering layer.
		Layer& GetLayer( void );

		/// \brief	Dispatch windows message to frame & client.
		bool DispatchMessages( HWND hWnd , UINT uMsg , WPARAM wParam , LPARAM lParam );

		/// \brief	Resize frame.
		void Resize( int w , int h );

		//@}

		/// \name XGui Component Attributes
		//@{

		/// \brief	Set size of component.
		virtual bool SetSize( const Pair<int>& size );

		/// \brief	Draw background.
		virtual void OnDrawBackground( Composition& composition );

		/// \brief	Request update.
		virtual void RequestUpdate( RefWeak<IGuiComp> comp , const Rect<int>& region );

		//@}

		/// \name Presentation Manipulation
		//@{

		/// \brief	Tick update.
		virtual void Tick( Updater& updater , float dTime ) { __super::Tick( updater , dTime ); }

		/// \brief	Draw XGUI component to composition.
		virtual void Draw( Composition& composition ) { __super::Draw( composition ); }

		//@}

	private:

		//@ data
		FrameBase&			m_window;
		Counter				m_updateCounter;
		Time				m_updateTime;
		Layer				m_layer;
	};

} // namespace xeres
